package com.qn.strategy.event;

import com.qn.strategy.ICouponDiscount;
import com.qn.strategy.eums.EnumPromotionType;
import com.qn.strategy.factory.PromotionTypeServiceStrategyFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * N元购
 *
 * @author Qning
 * @date 2021/09/09
 */
@Service
public class NYGCouponDiscount implements ICouponDiscount<Double>, InitializingBean {

    /**
     * n元购购买
     * 1. 无论原价多少钱都固定金额购买
     */
    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal skuPrice) {
        return new BigDecimal(couponInfo);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        PromotionTypeServiceStrategyFactory.register(EnumPromotionType.NY.getValue(), this);
    }
}
